package com.fhz.day006

import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.content.edit
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import kotlinx.android.synthetic.main.activity_main2.*

class Main2Activity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)

        val viewModel = ViewModelProvider(this).get(Main2ViewModel::class.java)

        tv1.text = viewModel.num.toString()

        btn1.setOnClickListener {
            viewModel.num++
            tv1.text = viewModel.num.toString()
        }

    }

}
